<!--
 * @Author: your name
 * @Date: 2019-10-22 09:06:18
 * @LastEditTime: 2019-10-31 11:13:23
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: /e:\yjp\my_test\vue_plugins\src\views\Websocket.vue
 -->
<template>
<div class="container">
    <van-nav-bar title="$root.global" left-arrow fixed :border="false"
      @click-left='$router.push("/global")'/>
    <van-cell-group>
        <van-field
            v-model="rootdata"
            label="全局数据"
            placeholder=""
            disabled
        >
        </van-field>
        <van-field
            v-model="rootname"
            label="name"
            placeholder="请输入"
        />
        <van-field
            v-model="rootvalue"
            label="value"
            placeholder="请输入"
        />
    </van-cell-group>
    <van-button  type="primary" size="small" @click.stop="Change">修改全局对象</van-button>
    
</div>
</template>
<script>
import { log } from 'util';
export default {
    name:"Globaldata",
    data(){
        return{
            rootdata:'',
            rootname:'',
            rootvalue:'',
        }
    },
    mounted(){
        this.init();
    },
    methods: {
        // 初始化数据
        init(){
            this.rootdata = JSON.stringify(this.$root.global);
        },
        // 添加全局对象
        Change(){
            let obj = {
                [this.rootname]:this.rootvalue
            }
            this.$root.global = {...obj,...this.$root.global};
            this.init();
        }
    },
}
</script>

<style lang="less" scoped>

</style>